package com.mx.zb.mng.ctrl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.RequestMapping;

import com.mx.zb.mng.bo.Operator;
import com.mx.zb.mng.dao.OperatorMapper;
import com.mx.zb.mng.utils.ex.PageAnnotation;

@Controller
@PageAnnotation
@RequestMapping("/pdemo")
public class ThymeleafDemoCtrl {
	
	@Autowired
	OperatorMapper operatorMapper;
	
	@RequestMapping("/")
	public String toLogin() {
		return "login";
	}
	
	@RequestMapping("/login")
	public String login(Operator o, Model model) {
		if(StringUtils.hasText(o.getName()) && StringUtils.hasText(o.getPassword())) {
			o=operatorMapper.validateLogin(o);
			if(o!=null) {
				return "dashboard";
			}
		}
		model.addAttribute("msg","您输入的用户名或者密码错误");
		return "login";
	}

	
	
}
